package easy;

public class Solution_1512 {
    public int numIdenticalPairs(int[] nums) {
        int[] flags = new int[101];
        for (int num : nums) {
            flags[num]++;
        }
        int count = 0;
        for (int flag : flags) {
            if (flag > 1) {
                count = count + flag * (flag - 1) / 2;
            }
        }
        return count;
    }

    public static void main(String[] args) {
        Solution_1512 model = new Solution_1512();
        System.out.println(model.numIdenticalPairs(new int[]{1, 2, 3, 1, 1, 3}));
        System.out.println(model.numIdenticalPairs(new int[]{1, 1, 1, 1}));
        System.out.println(model.numIdenticalPairs(new int[]{1, 2, 3}));
    }
}
